package com.csdj.t309springboot.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.annotation.Resource;
/**
 * web相关的配置类
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Resource
    private RedisService2 redisService2;
    private Logger log = LoggerFactory.getLogger("test");
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        log.info("添加拦截器 WebConfig => addInterceptors()");
        registry.addInterceptor(new LoginInterceptor(redisService2))
            .addPathPatterns("/**")//需要拦截的路径
                .excludePathPatterns("/login","/doLogin","/layui/**/","/register","/doRegister");//不需要拦截的路径
    }

    /**
     * 跳转视图页面
     * @param registry 视图控制器注册表
     */
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        //跳转到/login.html页面
        registry.addViewController("/login");//跳转到/login.html页面
        registry.addViewController("/login");//跳转到/login.html页面
        registry.addViewController("/register");
        registry.addViewController("/index");
        //转到后台页面
        registry.addViewController("/backend");
        registry.addViewController("/user");
        //publish
        registry.addViewController("/topic");

        //
        registry.addViewController("/account");
        registry.addViewController("/active");
        registry.addViewController("/article");
        registry.addViewController("/active");
        registry.addViewController("/active-details");

//        registry.addViewController("/info");
//        registry.addViewController("/active");

    }
}
